package com.JZ.QM.service.impl;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;

import com.JZ.QM.common.dao.ShareInfoDao;
import com.JZ.QM.common.entity.ShareInfoEntity;
import com.JZ.QM.service.ShareInfoService;

import javax.annotation.Resource;

/**
 *
 *
 * @author lyp
 * @email lyp@gmail.com
 * @date 2020-06-14 11:19:36
 */
@Service("shareInfoService")
public class ShareInfoServiceImpl extends ServiceImpl<ShareInfoDao, ShareInfoEntity> implements ShareInfoService {
    @Resource
    ShareInfoDao shareInfoDao;

    /**
     *
     * @param params
     * @return
     * @throws Exception
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<ShareInfoEntity> page = this.page(
                new Query<ShareInfoEntity>().getPage(params),
                new QueryWrapper<ShareInfoEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 根据策略Id筛选基金列表
     * @param shareIndustry 股票行业
     * @param shareMarket 股票市场类型
     * @param sharePerformation 股票的表现
     * @return
     */
    @Override
    public List<ShareInfoEntity> filtrateShareList(Integer shareIndustry, Integer shareMarket, Integer sharePerformation) {
        //条件构造器
        QueryWrapper<ShareInfoEntity> queryWrapper = new QueryWrapper<>();
        //股票列表
        List<ShareInfoEntity> shareInfoEntities = new ArrayList<>(10);

        //条件构造器封装复杂查询
        queryWrapper.eq("share_industry",shareIndustry)
                    .eq("share_market",shareMarket)
                    .eq("share_performation",sharePerformation);

        shareInfoEntities = shareInfoDao.selectList(queryWrapper);

        return shareInfoEntities;
    }

}